#include "UdpPointSetSwitchCmd.h"

UdpPointSetSwitchCmd::UdpPointSetSwitchCmd(QObject *parent) :
    BaseCmd(parent)
{
    this->m_protocolType = ProtocolType::PointProtocol;
    this->m_functionCode = FunctionCode;
    m_address = 0;
    m_value=0;
}


Package UdpPointSetSwitchCmd::toPackage()
{
    Package package;
    return package;
}

void UdpPointSetSwitchCmd::unPackage(Package package)
{
    m_address = package.body().mid(0,2).toHex().toInt(0,16);
    m_DeviceID= package.body().mid(4,2).toHex().toInt(0,16);
    m_valuelen= package.length()-8;
    qDebug()<<"!!!!!!!!!!!!!!!valuelen="<<m_valuelen;
    m_value =package.body().mid(6,m_valuelen);

    qDebug()<<"!!!!!!!!!!!!!!!value="<<m_value;
}


quint16 UdpPointSetSwitchCmd::address() const
{
    return m_address;
}
quint16 UdpPointSetSwitchCmd::DeviceID() const
{
    return m_DeviceID;
}
void UdpPointSetSwitchCmd::setAddress(const quint16 &address)
{
    m_address = address;
}

QByteArray UdpPointSetSwitchCmd::value() const
{
    return m_value;
}

void UdpPointSetSwitchCmd::setValue(QByteArray value)
{
    m_value = value;
}

UdpPointRelay::UdpPointRelay(QObject *parent) :
    BaseCmd(parent)
{
    this->m_protocolType = ProtocolType::PointProtocol;
    this->m_functionCode = FunctionCode;
    m_address = 0;
    m_value=0;
}

Package UdpPointRelay::toPackage()
{
    Package package;
    return package;
}

void UdpPointRelay::unPackage(Package package)
{
    m_address = package.body().mid(0,2).toHex().toInt(0,16);
    m_value =package.body().mid(2,2).toHex().toInt(0,16);
}

quint16 UdpPointRelay::address() const
{
    return m_address;
}

void UdpPointRelay::setAddress(const quint16 &address)
{
    m_address = address;
}

quint16 UdpPointRelay::value() const
{
    return m_value;
}

void UdpPointRelay::setValue(const quint16 &value)
{
    m_value = value;
}


